<template>
    <div class="right addLevel">
		<div class="level_tit tit clearfix">
			<span class="pull-left">添加会员等级</span>
			<router-link to="/vipLevel"><button class="btn btn-primary btn-sm pull-right add">返回等级列表</button></router-link>
		</div>
		<form action="" id="form">
			<p class="clearfix">
				<label for="name">会员等级名称:
					<input type="text" v-model="name" id="name">
				</label>
			</p>
			<p class="clearfix">
				<label for="icon">会员等级图标:
					<input type="file" id="icon">
				</label>
			</p>
			<p class="clearfix">
				<label for="discount">会员等级折扣:
					<input type="text" v-model="discount" id="discount">
				</label>
			</p>
			<p class="clearfix">
				<label for="type">&nbsp;&nbsp;&nbsp;&nbsp;会员类型组:
					<input type="checkbox" style="position:relative;top:3px;" v-model="type" id="type">是否为特殊会员组
				</label>
			</p>
			<p class="clearfix">
				<button class="btn btn-default" v-on:click.prevent="sure">确认</button>
			</p>
		</form>
	</div>
</template>
<script>
    import storage from '../js/common'
    export default {
        data(){
            return {
                name:"",
                file:"",
                discount:"",
                type:""
            }
        },
        methods:{
            sure:function(){
                let file = document.querySelector("#form").querySelector("input[type=file]");
                let obj = {
                    name:this.name,
                    discount:this.discount,
                    type:this.type,
                    file:require("../images/"+file.files[0].name)
                }
                storage("vip",obj);
                location.hash = "/vipLevel"
            }
        }
    }
</script>
<style scoped lang="css">
    form{
		padding-top:10px;
	}
	form p{
		height:30px;
	}
    a{
        color: #fff;
        text-decoration: none;
    }
    button a{
        display: block;
        width: 100%;
        height: 100%;
    }
    button a:hover{
        color: #fff;
        text-decoration: none;
    }
    form{
        width: 450px;
    }
    form input[type="file"]{
        display: inline;
    }
</style>